package com.xqboss.apps.enums.user;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * 身份晋升类型：
 */
public enum UserIdentityPromotionEnum {

    IDENTITY_CARD(0,"身份卡晋升","identityCard"),
    FRAGMENTS(1,"碎片晋升","fragments");
    private int code;
    private String des;
    private String promotion;

    UserIdentityPromotionEnum(int code, String des, String promotion) {
        this.code = code;
        this.des = des;
        this.promotion = promotion;
    }

    /*消耗藏品（身份卡或碎片数量）*/
    private static final String COST = "*1";


    public int code() {
        return code;
    }

    public String des() {
        return des;
    }

    public String promotion() {
        return promotion;
    }

    /**
     * 根据code获取资源消耗内容
     *
     * @param code 消耗类型
     * @return 资源消耗内容
     */
    public static String ResourceCost(Integer code) {
        return getDesByCode(code).concat(COST);
    }

    public static String getDesByCode(Integer code){
        return  Arrays.stream(UserIdentityPromotionEnum.values()).filter(u -> u.code() == code).map(UserIdentityPromotionEnum::des).collect(Collectors.joining(""));
    }

}
